package com.bw.services.model

import com.bw.common.http.NetUtils
import com.bw.services.entity.AddParkingEntity
import com.bw.services.entity.CarManage
import com.bw.services.entity.CarParkingEntity
import com.bw.services.entity.NewsEntity
import javax.inject.Inject

class ServicesRepo @Inject constructor(val apiServer: ServicesApiServer) {
    suspend fun getCar_Manage(licensePlate: String):CarManage?{
        val result = NetUtils.httpRequest { apiServer.getCar_manage(licensePlate)}
        if(result.code==200){
            return  result.data
        }
        return  null
    }

    suspend fun getCar_Parking(areaId: Int):List<CarParkingEntity>?{
        val result = NetUtils.httpRequest { apiServer.getCar_parking(areaId)}
        if(result.code==200){
            return  result.data
        }
        return  null
    }

    suspend fun getCar_Add_Parking(addParking: CarParkingEntity):CarParkingEntity?{
        val result = NetUtils.httpRequest { apiServer.getCar_Add_Parking(addParking)}
        if(result.code==200){
            return  result.data
        }
        return  null
    }
//
    suspend fun getUpData_Parking(id: Int,upData: CarParkingEntity):CarParkingEntity?{
        val result = NetUtils.httpRequest { apiServer.getCar_UpData_Parking(id,upData)}
        if(result.code==200){
            return  result.data
        }
        return  null
    }
    suspend fun getNews():List<NewsEntity>?{
        val result = NetUtils.httpRequest { apiServer.getNews()}
        if(result.code==200){
            return  result.data
        }
        return  null
    }
    suspend fun get_addNews(body: NewsEntity):NewsEntity?{
        val result = NetUtils.httpRequest { apiServer.addNews(body)}
        if(result.code==200){
            return  result.data
        }
        return  null
    }
}